//
//  GlobalModuleRouter.m
//  ShowYork
//
//  Created by hxh on 2021/2/20.
//  Copyright © 2021 hxh. All rights reserved.
//

#import "GlobalModuleRouter.h"
#import "MGJRouter.h"
#import "NavigationViewController.h"
#import "CampusDetailViewController.h"
#import "MinePageViewController.h"
#import "MineAccountSetViewController.h"
#import "ReportViewController.h"
#import "HomePageUserInfoViewController.h"
#import "DynamicPostViewController.h"
#import "RegisterViewController.h"
#import "LoginViewController.h"
#import "BindPhoneViewController.h"
#import "DynamicPostTopicListViewController.h"
#import "DynamicPhotoBrowserViewController.h"
#import "DynamicVideoBrowserViewController.h"
#import "MineFeedbackViewController.h"
#import "MineMessageListViewController.h"
#import "SLShotViewController.h"
#import "TabBarViewController.h"
#import "CampusListViewController.h"
#import "LessonDetailViewController.h"
#import "NewsListViewController.h"
#import "HomeTagItemModel.h"
#import "VoiceReadListViewController.h"
#import "LessonPageViewController.h"
#import "HomePageMainListViewController.h"

@implementation GlobalModuleRouter
+(void)load{
    [MGJRouter registerURLPattern:@"local://ddup/homePage/userInfo" toHandler:^(NSDictionary *routerParameters) {
        NavigationViewController *navigationVC = routerParameters[MGJRouterParameterUserInfo][@"navigationVC"];
        NSNumber *userId = routerParameters[MGJRouterParameterUserInfo][@"userId"];
        HomePageUserInfoViewController *userInfoVC = [[HomePageUserInfoViewController alloc]initWithUserId:userId];
        [navigationVC pushViewController:userInfoVC animated:YES];
    }];
    
    [MGJRouter registerURLPattern:@"local://ddup/report" toHandler:^(NSDictionary *routerParameters) {
        NavigationViewController *navigationVC = routerParameters[MGJRouterParameterUserInfo][@"navigationVC"];
        NSString *reportId = [routerParameters[MGJRouterParameterUserInfo][@"reportId"] stringValue];
        NSInteger reportType = [routerParameters[MGJRouterParameterUserInfo][@"reportType"] intValue];
        ReportViewController *reportVC = [[ReportViewController alloc]initWithReportType:reportType reportId:reportId];
        [navigationVC pushViewController:reportVC animated:YES];
    }];
    
    [MGJRouter registerURLPattern:@"local://ddup/release" toHandler:^(NSDictionary *routerParameters) {
        NavigationViewController *navigationVC = routerParameters[MGJRouterParameterUserInfo][@"navigationVC"];
        DynamicPostViewController *releaseVC = [[DynamicPostViewController alloc]init];
        if (routerParameters[MGJRouterParameterUserInfo][@"tag"] != nil) {
            releaseVC.targetTagModel = routerParameters[MGJRouterParameterUserInfo][@"tag"];
        }
        [navigationVC pushViewController:releaseVC animated:YES];
    }];
    
    [MGJRouter registerURLPattern:@"local://ddup/unLogin" toHandler:^(NSDictionary *routerParameters) {
        NavigationViewController *navigationVC = routerParameters[MGJRouterParameterUserInfo][@"navigationVC"];
        LoginViewController *loginVC = [[LoginViewController alloc]init];
        [navigationVC pushViewController:loginVC animated:NO];
    }];
    
    [MGJRouter registerURLPattern:@"local://ddup/register" toHandler:^(NSDictionary *routerParameters) {
        NavigationViewController *navigation = routerParameters[MGJRouterParameterUserInfo][@"navigationVC"];
        NSString *phone = routerParameters[MGJRouterParameterUserInfo][@"phone"];
        BOOL isAppLogin = [routerParameters[MGJRouterParameterUserInfo][@"appLogin"] boolValue];
        RegisterViewController *registerVC = [[RegisterViewController alloc]init];
        registerVC.isAppLogin = isAppLogin;
        registerVC.phoneStr = phone;
        [navigation pushViewController:registerVC animated:YES];
        
    }];
    
    [MGJRouter registerURLPattern:@"local://ddup/rootVC" toHandler:^(NSDictionary *routerParameters) {
        TabBarViewController *tabVC = [[TabBarViewController alloc]init];
        [UIApplication sharedApplication].keyWindow.rootViewController = tabVC;
    }];
    
    [MGJRouter registerURLPattern:@"local://ddup/bindPhone" toHandler:^(NSDictionary *routerParameters) {
        NavigationViewController *navigation = routerParameters[MGJRouterParameterUserInfo][@"navigationVC"];
        BindPhoneViewController *bindVC = [[BindPhoneViewController alloc]init];
        BOOL isAppLogin = [routerParameters[MGJRouterParameterUserInfo][@"appLogin"] boolValue];
        bindVC.isAppLogin = isAppLogin;
        bindVC.otherLoginModel = routerParameters[MGJRouterParameterUserInfo][@"otherLogin"];
        [navigation pushViewController:bindVC animated:YES];
    }];
    
    [MGJRouter registerURLPattern:@"local://ddup/newsList" toHandler:^(NSDictionary *routerParameters) {
        NavigationViewController *navigation = routerParameters[MGJRouterParameterUserInfo][@"navigationVC"];
        NewsListViewController *newList = [[NewsListViewController alloc]init];
        [navigation pushViewController:newList animated:YES];
    }];
    
    [MGJRouter registerURLPattern:@"local://ddup/releaseTagList" toHandler:^(NSDictionary *routerParameters) {
        NavigationViewController *navigation = routerParameters[MGJRouterParameterUserInfo][@"navigationVC"];
        DynamicPostTopicListViewController *tagListVC = [[DynamicPostTopicListViewController alloc]initWithSelectedTag:routerParameters[MGJRouterParameterUserInfo][@"tag"]];
        void(^block)(SocialSubTopicModel *itemModel) = routerParameters[MGJRouterParameterUserInfo][@"block"];
        tagListVC.selectedCurrentTagItem = block;
        [navigation pushViewController:tagListVC animated:YES];
    }];
    
    [MGJRouter registerURLPattern:@"local://ddup/releasePhotoBrowser" toHandler:^(NSDictionary *routerParameters) {
        NavigationViewController *navigation = routerParameters[MGJRouterParameterUserInfo][@"navigationVC"];
        DynamicPhotoBrowserViewController *browserVC = [[DynamicPhotoBrowserViewController alloc]initWithDataArray:routerParameters[MGJRouterParameterUserInfo][@"dataArray"] andSelectedIndex:[routerParameters[MGJRouterParameterUserInfo][@"index"] intValue]];
        void(^block)(NSInteger index) = routerParameters[MGJRouterParameterUserInfo][@"block"];
        browserVC.done = block;
        [navigation pushViewController:browserVC animated:YES];
    }];
    
    [MGJRouter registerURLPattern:@"local://ddup/releaseVideoBrowser" toHandler:^(NSDictionary *routerParameters) {
        NavigationViewController *navigation = routerParameters[MGJRouterParameterUserInfo][@"navigationVC"];
        NSString *url = routerParameters[MGJRouterParameterUserInfo][@"url"];
        void(^block)(void) = routerParameters[MGJRouterParameterUserInfo][@"block"];
        DynamicVideoBrowserViewController *browserVC = [[DynamicVideoBrowserViewController alloc]init];
        browserVC.videoUrl = url;
        browserVC.removeVideo = block;
        [navigation pushViewController:browserVC animated:YES];
    }];
    
    [MGJRouter registerURLPattern:@"local://ddup/releaseShotView" toHandler:^(NSDictionary *routerParameters) {
        UIViewController *currentVC = routerParameters[MGJRouterParameterUserInfo][@"currentVC"];
        NSNumber *type = routerParameters[MGJRouterParameterUserInfo][@"type"];
        BOOL isVideo = [routerParameters[MGJRouterParameterUserInfo][@"isVideo"] boolValue];
        SLShotViewController *shotVC = [[SLShotViewController alloc]initWithShotType:type onlyPhoto:isVideo];
        shotVC.modalPresentationStyle = UIModalPresentationFullScreen;
        [currentVC presentViewController:shotVC animated:YES completion:nil];
    }];
    [MGJRouter registerURLPattern:@"local://ddup/mine/feedback" toHandler:^(NSDictionary *routerParameters) {
        NavigationViewController *navigation = routerParameters[MGJRouterParameterUserInfo][@"navigationVC"];
        MineFeedbackViewController *feedbackVC = [[MineFeedbackViewController alloc]init];
        [navigation pushViewController:feedbackVC animated:YES];
    }];
    [MGJRouter registerURLPattern:@"local://ddup/mine/set" toHandler:^(NSDictionary *routerParameters) {
        NavigationViewController *navigation = routerParameters[MGJRouterParameterUserInfo][@"navigationVC"];
        MineAccountSetViewController *setVC = [[MineAccountSetViewController alloc]init];
        void(^block)(void) = routerParameters[MGJRouterParameterUserInfo][@"block"];
        setVC.refresh = block;
        [navigation pushViewController:setVC animated:YES];
    }];
    [MGJRouter registerURLPattern:@"local://ddup/mine/messageList" toHandler:^(NSDictionary *routerParameters) {
        NavigationViewController *navigation = routerParameters[MGJRouterParameterUserInfo][@"navigationVC"];
        MineMessageListViewController *listVC = [[MineMessageListViewController alloc]init];
        [navigation pushViewController:listVC animated:YES];
    }];
    
    [MGJRouter registerURLPattern:@"local://ddup/campus/detail" toHandler:^(NSDictionary *routerParameters) {
        NavigationViewController *navigation = routerParameters[MGJRouterParameterUserInfo][@"navigationVC"];
        CampusDetailViewController *dtlVC = [[CampusDetailViewController alloc]init];
        dtlVC.schId = routerParameters[MGJRouterParameterUserInfo][@"schId"];
        [navigation pushViewController:dtlVC animated:YES];
    }];
    [MGJRouter registerURLPattern:@"local://ddup/campus/list" toHandler:^(NSDictionary *routerParameters) {
        NavigationViewController *navigation = routerParameters[MGJRouterParameterUserInfo][@"navigationVC"];
        CampusListViewController *listVC = [[CampusListViewController alloc]init];
        [navigation pushViewController:listVC animated:YES];
    }];
    [MGJRouter registerURLPattern:@"local://ddup/lesson/detail" toHandler:^(NSDictionary *routerParameters) {
        NavigationViewController *navigation = routerParameters[MGJRouterParameterUserInfo][@"navigationVC"];
        LessonDetailViewController *dtlVC = [[LessonDetailViewController alloc]init];
        dtlVC.lessonId = routerParameters[MGJRouterParameterUserInfo][@"lessonId"];
        [navigation pushViewController:dtlVC animated:YES];
    }];
    [MGJRouter registerURLPattern:@"local://ddup/discover/parentKnow" toHandler:^(NSDictionary *routerParameters) {
        NavigationViewController *navigation = routerParameters[MGJRouterParameterUserInfo][@"navigationVC"];
        NewsListViewController *listVC = [[NewsListViewController alloc]init];
        [navigation pushViewController:listVC animated:YES];
    }];
    
    [MGJRouter registerURLPattern:@"local://ddup.app/voice/voiceList" toHandler:^(NSDictionary *routerParameters) {
        NavigationViewController *navigation = routerParameters[MGJRouterParameterUserInfo][@"navigationVC"];
        VoiceReadListViewController *listVC = [[VoiceReadListViewController alloc]init];
        [navigation pushViewController:listVC animated:YES];
    }];
    [MGJRouter registerURLPattern:@"local://ddup.app/lesson/lessonList" toHandler:^(NSDictionary *routerParameters) {
        NavigationViewController *navigation = routerParameters[MGJRouterParameterUserInfo][@"navigationVC"];
        LessonPageViewController *listVC = [[LessonPageViewController alloc]init];
        [navigation pushViewController:listVC animated:YES];
    }];
    
    [MGJRouter registerURLPattern:@"local://ddup.app/user/loginUserInfo" toHandler:^(NSDictionary *routerParameters) {
        NavigationViewController *navigation = routerParameters[MGJRouterParameterUserInfo][@"navigationVC"];
        MinePageViewController *mineVC = [[MinePageViewController alloc]init];
        [navigation pushViewController:mineVC animated:YES];
    }];
    
    [MGJRouter registerURLPattern:@"local://ddup.app/home/homeList" toHandler:^(NSDictionary *routerParameters) {
        NavigationViewController *navigation = routerParameters[MGJRouterParameterUserInfo][@"navigationVC"];
        HomePageMainListViewController *listVC = [[HomePageMainListViewController alloc]init];
        [navigation pushViewController:listVC animated:YES];
    }];
}

@end
